#include <stdio.h>

int classwise(unsigned char *ip)
{
    if (ip[0] >= 0 && ip[0] <= 127)        return 0;  // A 类
    else if (ip[0] >= 128 && ip[0] <= 191) return 1;  // B 类
    else if (ip[0] >= 192 && ip[0] <= 223) return 2;  // C 类
    else if (ip[0] >= 224 && ip[0] <= 239) return 3;  // D 类
    else if (ip[0] >= 240 && ip[0] <= 255) return 4;  // E 类
    else                                   return -1; // 错误
}

int main()
{
    unsigned char ip[4] = {192, 168, 1, 100};
    char IPClass[] = "ABCDE";
    printf("IP address is in class %c.\n", IPClass[classwise(ip)]);
    return 0;
}